#include "CEvent.h"



//////////////////////////////////////////////////////////

void	CEvent::SetSwitches(bool enabled)
{
	b_SwitchesEnabled = enabled;
}


bool	CEvent::SwitchesEnabled()
{
	return b_SwitchesEnabled;
}

void	CEvent::SetSwitchesList(std::list<EventSwitch_t> *l_switches)
{
	this->l_Switches = l_switches;
}


EventSwitch_t* CEvent::GetSwitch(char id)
{
	for(std::list<EventSwitch_t>::iterator it = l_Switches->begin();
			it != l_Switches->end(); it++)
	{
		if( ((EventSwitch_t)(*it)).c_switch == id ) return (EventSwitch_t*)&(*it);
	}
	return NULL;
}

void	CEvent::AddSwitchInfo(char id, bool hasValue)
{
	EventSwitchInfo_t *esi = new EventSwitchInfo_t;
	esi->c_switch = id;
	esi->value = hasValue;
	this->l_SwitchesInfo.push_back(esi);
}

EventSwitchInfo_t* CEvent::GetSwitchInfo(char id)
{
	for(std::list<EventSwitchInfo_t*>::iterator it= l_SwitchesInfo.begin();
		it != l_SwitchesInfo.end(); ++it)
	{
		if(((EventSwitchInfo_t*)*it)->c_switch == id) 
		{
			return ((EventSwitchInfo_t*)*it);
		}
	}
	return NULL;
}

void	CEvent::RemoveSwitch(char id)
{
	if(l_Switches)
	{
		EventSwitch_t * e=GetSwitch(id);
		if(e) l_Switches->remove((*e));
	}
}